package cn.itlaobing.service;

import cn.itlaobing.entity.Goods;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/11/20 0020.
 */
public class GoodsService {

    private static List<Goods> goodsList=new ArrayList<>();

    static{
        Goods goods=new Goods();
        goods.setId(1000);
        goods.setName("洗衣粉");
        goods.setPrice(30.00F);
        goodsList.add(goods);


        goods=new Goods();
        goods.setId(2000);
        goods.setName("洗手液");
        goods.setPrice(10.00F);
        goodsList.add(goods);
    }

    public GoodsService() {


    }

    public List<Goods> findAll(){
        return goodsList;
    }

    public Goods findById(Integer goodsId){
        for(Goods goods:goodsList){
            if(goods.getId().equals(goodsId)){
                return goods;
            }
        }
        return null;
    }







}
